package liurong.driver.thread;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.junit.Test;

public class ScheduledThreadTest {

	private int num = 0;
	ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);

	@Test
	public void test1() throws Exception {

		executor();

		System.in.read();
	}

	private void executor() {
		executor.schedule(() -> {
			System.out.println(num++);
			executor();
		}, 1, TimeUnit.SECONDS);
	}
}
